﻿using System;
using System.ComponentModel;
using System.Configuration.Install;
using System.Reflection;
using System.ServiceProcess;
using System.Threading;
using Grundy.Licensing.Server;
using Grundy.Common;

namespace Grund.Licensing.Server.Host
{
    public class Service : ServiceBase
    {
        private Application _application;

        protected override void OnShutdown()
        {
            _application.LicenseServer.Shutdown();
            Thread.Sleep(1000);
        }

        protected override void OnStart(string[] args)
        {
            var worker = new Thread(() => { _application = Application.Instance; });
            worker.Start();
            base.OnStart(args);
        }

        private void InitializeComponent()
        {
            // 
            // Service
            // 
            this.CanShutdown = true;
            this.ServiceName = "Grundy license manager";

        }
    }
}